home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / tcisam.zip / IREADR.C < prev    next >
Text File  |  1987-08-21  |  1KB  |  38 lines

  1. /*
  2.  * IREADR.C - Random read
  3.  *
  4.  *                      Copyright (c) 1987, Jim Mischel
  5.  * Modifications:
  6.  *
  7.  * 08/13/87 - jim - original coding
  8.  */
  9.  
  10. #include "inxdefs.h"
  11.  
  12. /*
  13.  * iread() - return the record referenced by the key value in destination
  14.  * record.  If successful, returns 0 with data record in destin.
  15.  * If unsuccessful, returns error status and the data at destin is unchanged.
  16.  *
  17.  * This routine assumes there is enough space at 'dest' to store the    entire
  18.  * data record.
  19.  */
  20. int iread(void *d, void *dest)
  21. {
  22.   register df_rec *db_control = (df_rec *)d;
  23.   char *destin = (char *)dest;
  24.  
  25.   /* find the record */
  26.   if (isearch(db_control,(destin+db_control->df_key_offset)) == 0) {
  27.     /* record found, copy into user's buffer */
  28.     memcpy(destin,db_control->df_dat_buff,db_control->df_rec_size);
  29.     db_control->df_flags &= ~DF_DELETE;
  30.     return(0);
  31.   }
  32.   else {
  33.     if (ierrno == 0)
  34.       ierror(I_NOREC);
  35.     return(I_NOREC);
  36.   }
  37. } /* iread */
  38.